CString::operator +

friend CString operator +( const CString& string1, const CString& string2 );
  throw( CMemoryException );
friend CString operator +( const CString& string, TCHAR ch );
  throw( CMemoryException );
friend CString operator +( TCHAR ch, const CString& string );
  throw( CMemoryException );
friend CString operator +( const CString& string, LPCTSTR lpsz );
  throw( CMemoryException );
friend CString operator +( LPCTSTR lpsz, const CString& string );
  throw( CMemoryException );

返回值:
返回一个CString对象,该对象是此连接操作的临时结果。这个返回值使得在一个表达式中组合多次连接成为可能。

参数:
string,string1,string2要连接的CString对象。
ch将被连接到一个字符串之后的或将在其后连接一个字符串的字符。
lpsz指向一个以空字符结尾的字符串的指针。

说明:
此+操作符将两个字符串连接起来并返回一个CString对象。两个参数中的一个必须是一个CString对象,而另一个可以是指向字符的指针或是一个字符。不管你什么时候使用这个连接操作符,都要小心可能出现的内存异常,因为为了保存这个临时结果常常要分配新内存。

示例:
下面的例子说明了如何使用CString::operator +。
// CString::operator +示例:
CString s1( "abc" );
CString s2( "def" );
ASSERT( (s1 + s2 ) == "abcdef" );
CString s3;
s3 = CString( "abc" ) + "def"; // Correct
s3 = "abc" + "def";
// 错了!第一个参数必须是一个CString。

请参阅:CString::operator +=